#include <bits/stdc++.h>
using namespace std;
#define int long long

int k, m, q, l, r, x;
string s;


signed main() {
	freopen("copy.in", "r", stdin);
	freopen("copy.out", "w", stdout);
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> k >> m >> s >> q;
	while (q--) {
		cin >> l >> r >> x;
		string ns;
		int tot = 0;
		for (int i = 0; i < x; ++i) {
			ns += s[i];
			if (++tot == m) goto end;
		}
		for (int i = l; i < r; ++i) {
			if (++tot == m) goto end;
			ns += s[i];
		}
		for (int i = x; i < s.size(); ++i) {
			ns += s[i];
			if (++tot == m) goto end;
		}
		end: s = ns;
	}
	for (auto i : s) {
		if (k) {
			cout << i;
			--k;
		}
		else return 0;
	}
	return 0;
}
